<template>
	<view class="search">
		<view class="bg-img">
			<u-image width="750rpx" height="374rpx" src="@/pagesA/static/bg_img.png"></u-image>
		</view>
		<!-- 搜索框区域 -->
		<u-search @search="search" margin="20rpx 20rpx 0rpx" bg-color="rgba(255, 255, 255, 0.3)" :show-action="false" border-color="#fff" shape="square"
			placeholder="请输入查询内容" search-icon-color="#fff" placeholder-color="#fff" v-model="keyword"></u-search>
		<search-list :keyword="text" :list="list" v-if="Object.keys(list).length > 0"></search-list>
		<view class="search-icon" v-else>
			<!-- <u-icon name="search" color="#eee" size="200"></u-icon> -->
			<u-empty mode="search"></u-empty>
		</view>
	</view>
</template>

<script>
	import SearchList from './search_list/index.vue'
	import { apiGetAppealByTitle } from '@/api/backlog/backlog.js'
	export default {
		name: 'Search',
		components: { SearchList },
		data () {
			return {
				keyword: '',
				text: '',
				list: []
			}
		},
		methods: {
			//搜索事件
			search (e) {
				this.apiGetAppealByTitle(e).catch(err => {
					console.log(err)
				})
				console.log(e)
				console.log(this.keyword)
			},
			//根据标题搜索待办
			async apiGetAppealByTitle (key) {
				const res = await apiGetAppealByTitle(key);
				this.text = key;
				this.list = res.data.list;
				console.log(res);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.search {
		// padding: 20rpx;
		overflow: hidden;
	}
	.bg-img {
		position: absolute;
		left: 0;
		top: 0;
		right: 0;
		z-index: -1;
	}
	
	.search-icon {
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 30rpx;
		margin: 0 auto;
		margin-top: 20rpx;
		width: 710rpx;
		height: calc(100vh - 106rpx);
		// overflow-y: auto;
		// min-height: 686rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
	}
</style>
